cmake_minimum_required(VERSION 3.16) # ��С֧�ֵ�cmake�汾

#define MYLIB_EXPORTS 1 宏定义注释掉

project(QP_6Aix) 

# set(CMAKE_MAKE_PROGRAM "D:/APP/w64devkit-1.16.0/w64devkit/bin/mingw32-make.exe")
# set(CMAKE_C_COMPILER "D:/APP/w64devkit-1.16.0/w64devkit/bin/gcc.exe")
# set(CMAKE_CXX_COMPILER "D:/APP/w64devkit-1.16.0/w64devkit/bin/g++.exe")

# ���� C++ ��׼Ϊ C++20����ǿ��ʹ��
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall")


#find_package(PkgConfig REQUIRED)
#find_package(EtherCAT REQUIRED)
#find_package(libmodbus REQUIRED)
#pkg_check_modules(LIBMODBUS REQUIRED libmodbus)


include_directories(. Define Middle POCO Protocol TcpPack Intf ThirdPart/spdlog/include)
#include_directories(${LIBMODBUS_INCLUDE_DIRS})

# 添加spdlog子目录（不编译测试和示例）
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "Disable spdlog tests")
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "Disable spdlog examples")
add_subdirectory(ThirdPart/spdlog)

aux_source_directory(. DIR_SRCS) 
aux_source_directory(Define Define_SRC_LIST)
aux_source_directory(Middle Middle_SRC_LIST)
aux_source_directory(POCO POCO_SRC_LIST)
aux_source_directory(Protocol Protocol_SRC_LIST)
aux_source_directory(TcpPack TcpPack_SRC_LIST)
aux_source_directory(Intf Intf_SRC_LIST)

add_executable(Qp6Aix ${DIR_SRCS} ${Define_SRC_LIST} ${Middle_SRC_LIST} ${POCO_SRC_LIST} ${Protocol_SRC_LIST} ${TcpPack_SRC_LIST} ${Intf_SRC_LIST}) # 指定程序入口

# 链接spdlog库（头文件库，无需链接，但需包含头文件路径）
target_link_libraries(Qp6Aix PRIVATE spdlog::spdlog)
target_link_libraries(Qp6Aix PUBLIC pthread)
target_link_libraries(Qp6Aix PRIVATE ws2_32)


#-------------------编译 lib---------------------------------------------



# cmake_minimum_required(VERSION 3.16) # ��С֧�ֵ�cmake�汾
# project(QP_6Aix_Lib VERSION 1.0.0 LANGUAGES CXX)



# # set(CMAKE_MAKE_PROGRAM "D:/APP/w64devkit-1.16.0/w64devkit/bin/mingw32-make.exe")
# # set(CMAKE_C_COMPILER "D:/APP/w64devkit-1.16.0/w64devkit/bin/gcc.exe")
# # set(CMAKE_CXX_COMPILER "D:/APP/w64devkit-1.16.0/w64devkit/bin/g++.exe")

# # ���� C++ ��׼Ϊ C++20����ǿ��ʹ��
# set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)

# set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
# set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall")

# set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")

# #find_package(PkgConfig REQUIRED)
# #find_package(EtherCAT REQUIRED)
# #find_package(libmodbus REQUIRED)
# #pkg_check_modules(LIBMODBUS REQUIRED libmodbus)


# include_directories(. Define Middle POCO Protocol TcpPack Intf ThirdPart/spdlog/include)
# #include_directories(${LIBMODBUS_INCLUDE_DIRS})

# # 添加spdlog子目录（不编译测试和示例）
# set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "Disable spdlog tests")
# set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "Disable spdlog examples")
# add_subdirectory(ThirdPart/spdlog)

# aux_source_directory(. DIR_SRCS) 
# aux_source_directory(Define Define_SRC_LIST)
# aux_source_directory(Middle Middle_SRC_LIST)
# aux_source_directory(POCO POCO_SRC_LIST)
# aux_source_directory(Protocol Protocol_SRC_LIST)
# aux_source_directory(TcpPack TcpPack_SRC_LIST)
# aux_source_directory(Intf Intf_SRC_LIST)

# #编译静态库     #记得修改 QP_Intf.h 中的编译宏定义
# # add_library(Qp6AixLib 
# #     STATIC  # ��̬�⣨.a �� .lib��
# #     # SHARED  # ��̬�⣨.so �� .dll��
# #     ${DIR_SRCS} ${Define_SRC_LIST} ${Middle_SRC_LIST} ${POCO_SRC_LIST} ${Protocol_SRC_LIST} ${TcpPack_SRC_LIST} ${Intf_SRC_LIST}
# # )
# #编译动态库     #记得修改 QP_Intf.h 中的编译宏定义
# add_library(Qp6AixLib 
#     #STATIC  # ��̬�⣨.a �� .lib��
#     SHARED  # ��̬�⣨.so �� .dll��
#     ${DIR_SRCS} ${Define_SRC_LIST} ${Middle_SRC_LIST} ${POCO_SRC_LIST} ${Protocol_SRC_LIST} ${TcpPack_SRC_LIST} ${Intf_SRC_LIST}
# )


# target_link_libraries(Qp6AixLib PRIVATE spdlog::spdlog)
# target_link_libraries(Qp6AixLib PUBLIC pthread)
# target_link_libraries(Qp6AixLib PUBLIC ws2_32)
